//
//  ElectronPayMedthodTableViewCell.m
//  PropertyManager
//
//  Created by TNG on 2018/8/4.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "ElectronPayMedthodTableViewCell.h"

@implementation ElectronPayMedthodTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
        self.backgroundColor = SFM242;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

-(void)creatUI{
    [self.contentView addSubview:self.bgview];
    [self.bgview addSubview:self.timeLabel];
    [self.bgview addSubview:self.timeDetailLabel];
    [self.bgview addSubview:self.reallyTimeLabel];
    [self.bgview addSubview:self.reallyTimeDetailLabel];
    [self.bgview addSubview:self.userLabel];
    [self.bgview addSubview:self.userDetailLabel];
    [self.bgview addSubview:self.payWayLabel];
    [self.bgview addSubview:self.payWayDetailLabel];
    [self.bgview addSubview:self.dealLabel];
    [self.bgview addSubview:self.dealDetailLabel];
    [self.bgview addSubview:self.dashedView];
    [self drawDashLine:self.dashedView lineLength:4 lineSpacing:1 lineColor:SFM242];
}

-(UIView *)bgview
{
    if (_bgview == nil) {
        _bgview = [[UIView alloc] initWithFrame:CGRectMake(15, 0, WIDTH - 30, 192)];
        _bgview.backgroundColor = SFMWhiteColor;
    }
    return _bgview;
}

-(UILabel *)timeLabel
{
    if (_timeLabel == nil) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 23, 100, 17)];
        _timeLabel.font = font(14);
        _timeLabel.textColor = SFM153;
        _timeLabel.textAlignment = NSTextAlignmentLeft;
        _timeLabel.text = @"缴费时段";
    }
    return _timeLabel;
}

-(UILabel *)timeDetailLabel
{
    if (_timeDetailLabel == nil) {
        _timeDetailLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 23, WIDTH - 180, 17)];
        _timeDetailLabel.font = font(14);
        _timeDetailLabel.textColor = SFM51;
        _timeDetailLabel.textAlignment = NSTextAlignmentRight;
    }
    return _timeDetailLabel;
}

-(UILabel *)reallyTimeLabel
{
    if (_reallyTimeLabel == nil) {
        _reallyTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 53, 100, 17)];
        _reallyTimeLabel.font = font(14);
        _reallyTimeLabel.textColor = SFM153;
        _reallyTimeLabel.textAlignment = NSTextAlignmentLeft;
        _reallyTimeLabel.text = @"实际缴费时间";
    }
    return _reallyTimeLabel;
}

-(UILabel *)reallyTimeDetailLabel
{
    if (_reallyTimeDetailLabel == nil) {
        _reallyTimeDetailLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 53, WIDTH - 180, 17)];
        _reallyTimeDetailLabel.font = font(14);
        _reallyTimeDetailLabel.textColor = SFM51;
        _reallyTimeDetailLabel.textAlignment = NSTextAlignmentRight;
    }
    return _reallyTimeDetailLabel;
}

-(UILabel *)userLabel
{
    if (_userLabel == nil) {
        _userLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 83, 100, 17)];
        _userLabel.font = font(14);
        _userLabel.textColor = SFM153;
        _userLabel.textAlignment = NSTextAlignmentLeft;
        _userLabel.text = @"收款人账号";
    }
    return _userLabel;
}

-(UILabel *)userDetailLabel
{
    if (_userDetailLabel == nil) {
        _userDetailLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 83, WIDTH - 180, 17)];
        _userDetailLabel.font = font(14);
        _userDetailLabel.textColor = SFM51;
        _userDetailLabel.textAlignment = NSTextAlignmentRight;
    }
    return _userDetailLabel;
}

-(UILabel *)payWayLabel
{
    if (_payWayLabel == nil) {
        _payWayLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 113, 100, 17)];
        _payWayLabel.font = font(14);
        _payWayLabel.textColor = SFM153;
        _payWayLabel.textAlignment = NSTextAlignmentLeft;
        _payWayLabel.text = @"支付方式";
    }
    return _payWayLabel;
}

-(UILabel *)payWayDetailLabel
{
    if (_payWayDetailLabel == nil) {
        _payWayDetailLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 113, WIDTH - 180, 17)];
        _payWayDetailLabel.font = font(14);
        _payWayDetailLabel.textColor = SFM51;
        _payWayDetailLabel.textAlignment = NSTextAlignmentRight;
    }
    return _payWayDetailLabel;
}

-(UILabel *)dealLabel
{
    if (_dealLabel == nil) {
        _dealLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 143, 100, 17)];
        _dealLabel.font = font(14);
        _dealLabel.textColor = SFM153;
        _dealLabel.textAlignment = NSTextAlignmentLeft;
        _dealLabel.text = @"交易状态";
    }
    return _dealLabel;
}

-(UILabel *)dealDetailLabel
{
    if (_dealDetailLabel == nil) {
        _dealDetailLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 143, WIDTH - 180, 17)];
        _dealDetailLabel.font = font(14);
        _dealDetailLabel.textColor = SFM51;
        _dealDetailLabel.textAlignment = NSTextAlignmentRight;
    }
    return _dealDetailLabel;
}

-(UIView *)dashedView
{
    if (_dashedView == nil) {
        _dashedView = [[UIView alloc] initWithFrame:CGRectMake(20, 178, WIDTH - 70, 1)];
    }
    return _dashedView;
}


- (void)drawDashLine:(UIView *)lineView lineLength:(int)lineLength lineSpacing:(int)lineSpacing lineColor:(UIColor *)lineColor
{
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    [shapeLayer setBounds:lineView.bounds];
    [shapeLayer setPosition:CGPointMake(CGRectGetWidth(lineView.frame) / 2, CGRectGetHeight(lineView.frame))];
    [shapeLayer setFillColor:[UIColor clearColor].CGColor];
    
    //  设置虚线颜色为
    [shapeLayer setStrokeColor:lineColor.CGColor];
    
    //  设置虚线宽度
    [shapeLayer setLineWidth:CGRectGetHeight(lineView.frame)];
    [shapeLayer setLineJoin:kCALineJoinRound];
    
    //  设置线宽，线间距
    [shapeLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:lineLength], [NSNumber numberWithInt:lineSpacing], nil]];
    
    //  设置路径
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 0, 0);
    CGPathAddLineToPoint(path, NULL, CGRectGetWidth(lineView.frame), 0);
    
    [shapeLayer setPath:path];
    CGPathRelease(path);
    
    //  把绘制好的虚线添加上来
    [lineView.layer addSublayer:shapeLayer];
}

-(void)send
{
    self.timeDetailLabel.text = @"2018.09.15 - 2018.10.15";
    self.reallyTimeDetailLabel.text = @"2018.10.15";
    self.userDetailLabel.text = @"1232094387958432";
    self.payWayDetailLabel.text = @"支付宝支付";
    self.dealDetailLabel.text = @"交易成功";
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
